package com.imy.lua.dialog;

import android.view.View;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;

import com.imy.common.base.BaseDialog;
import com.imy.common.base.BaseKeyboardDialog;
import com.imy.lua.R;

public class ImageColorMenuDialog extends BaseKeyboardDialog {
    private LinearLayout cropLl;
    private LinearLayout savePicLl;
    private LinearLayout searchTargetLl;
    private LinearLayout getOneColorLl;
    private LinearLayout findColorInRegionLl;
    public ImageColorMenuDialog(AppCompatActivity activity) {
        super(activity);
    }

    @Override
    protected void init(View view) {
        super.init(view);
        getOneColorLl = view.findViewById(R.id.get_one_color);
        findColorInRegionLl=view.findViewById(R.id.find_color_in_region);
        cropLl = view.findViewById(R.id.crop_target_ll);
        savePicLl = view.findViewById(R.id.save_pic_ll);
        searchTargetLl = view.findViewById(R.id.target_file_ll);
        searchTargetLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener != null) {
                    listener.onSearchTargetImage();
                }
            }
        });
        findColorInRegionLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener!=null){
                    listener.onFindColorInRegion();
                }
            }
        });
        cropLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener != null) {
                    listener.onCropClicked();
                }
            }
        });
        savePicLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener != null) {
                    listener.onSavePic();
                }
            }
        });
        getOneColorLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener!=null){
                    listener.onGetOneColor();
                }
            }
        });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_image_color_menu;
    }

    public interface ImageColorMenuListener {
        void onCropClicked();

        void onSavePic();

        void onSearchTargetImage();

        void onGetOneColor();

        void onFindColorInRegion();
    }

    public void setImageColorMenuListener(ImageColorMenuListener listener) {
        this.listener = listener;
    }

    private ImageColorMenuListener listener;
}
